const express = require("express");
const router = express.Router();
var multipart = require('connect-multiparty');
const {publicArtical,delArtical,searchArtical,updateArtical,exportExcel,publicDraftArtical,searchArticalDetailById} = require("../rooterhandler/article");
const {addArticleSchema,removeArticleSchema,updateArticleSchema,getUserArticalSchema} = require("../schema/article")
// 导入formdata数据的中间件
var multipartMiddleware = multipart();
// 导入验证数据的中间件
const expressJoi = require("@escook/express-joi");
// 发布新文章
router.post("/add",multipartMiddleware,expressJoi(addArticleSchema),publicArtical);
// 发布草稿文章
router.post("/addDraft",multipartMiddleware,publicDraftArtical);
// 删除文章
router.post("/delete",multipartMiddleware,expressJoi(removeArticleSchema),delArtical);
// 查询文章列表
router.post("/search",multipartMiddleware,searchArtical)
// 查询文章详情
router.post("/searchArticle",multipartMiddleware,searchArticalDetailById)

// 修改文章
router.post("/update",multipartMiddleware,expressJoi(updateArticleSchema),updateArtical)
// 导出文章表
// router.post("/exportexcel",multipartMiddleware,exportExcel)

module.exports = router;